package xzl.edu.cn.set.demo;

import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintStream;
import java.io.PrintWriter;


import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

public class FilePrint {
	Logger logger = LogManager.getLogger(FilePrint.class);
    /**
     * 
     * @param filename1 源文件
     * @param filename2 目标文件
     */
	public void writePrint(String filename1, String filename2) {
		try {
			FileReader fr = new FileReader(filename1);
			BufferedReader bf=new BufferedReader(fr);
			FileWriter fw=new FileWriter(filename2);
			PrintWriter pw = new PrintWriter(fw);
            String str=bf.readLine();
            while(str!=null) {
            	pw.println(str);
            	str=bf.readLine();
            }
            fr.close();
            fw.close();
            bf.close();
            pw.close();
		} catch (FileNotFoundException e) {
			logger.info("找不到目标文件");
			e.printStackTrace();
		} catch (IOException e) {
			logger.info("读取失败！");
			e.printStackTrace();
		}

	}

}
